<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>房产模块-小区信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>
<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">名称</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="name" placeholder="请输入名称" style="width: 120px;" /></label>
			<label class="layui-input-inline">房屋类型</label>
			<label class="layui-input-inline" style="width: 160px;">
				<select name="hostType" id="hostType"  ></select>
			</label>
			<label class="layui-input-inline">分销状态</label>
			<label class="layui-input-inline" style="width: 160px;">
				<select name="shareType" id="shareType" ></select>
			</label>
			<label class="layui-input-inline">热卖新房</label>
			<label class="layui-input-inline" style="width: 160px;">
				<select name="hotSaleState" id="hotSaleState" ></select>
			</label>
			<a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a><a class="layui-btn layui-btn-normal addBtn" data-title="添加" data-url="/hostItem/getEntity">添加</a></div>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'pageUtil', 'fileUtil', 'table', 'dateUtil'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            table = layui.table,
            fileUtil = layui.fileUtil,
            pageUtil = layui.pageUtil;
        var tableIns = null;
        pageUtil.initDictByUrl("/hostType/acceptSelect","host_host_type",
            function(dictDataurl) {
        pageUtil.initDict("host_share_type,host_hot_sale_state",
            function(dictData) {
                pageUtil.showDict($("#hostType"), pageUtil.aceeptDictContentList(dictDataurl, "host_host_type"), "请选择房屋类型");
                pageUtil.showDict($("#shareType"), pageUtil.aceeptDictContentList(dictData, "host_share_type"), "请选择分销状态");
                pageUtil.showDict($("#hotSaleState"), pageUtil.aceeptDictContentList(dictData, "host_hot_sale_state"), "请选择热卖新房");
                var url = "/hostItem/page";
                var cols = [{
                    type: 'checkbox',
                    fixed: 'left'
                },
                    {
                        type: 'numbers',
                        title: '序号'
                    },
                    {
                        field: 'name',
                        title: '名称',
                        align: 'center',
						width:200
                    },
                    {
                        field: 'coverImage',
                        title: '封面图',
                        align: 'center',
                        templet: function(d) {
                            return "<img lay-event ='showPicture' src='"+d.coverImage+"' style='width:auto; max-width: 96%; height: 40px;'/>";
                        }
                    },
                    {
                        field: 'price',
                        title: '均价',
                        align: 'center'
                    },
                    {
                        field: 'minApartmentArea',
                        title: '面积',
                        align: 'center',
						width:120,
						templet: function(d) {
                        	return d.minApartmentArea+"-"+d.maxApartmentArea+"平方";
                    	}
                    },
                    {
                        field: 'minRooms',
                        title: '户型',
                        align: 'center',
                        templet: function(d) {
                            return d.minRooms+"-"+d.maxRooms+"室";
                        }
                    },
                    {
                        field: 'cityName',
                        title: '城市区域',
                        align: 'center',
                        templet: function(d) {
                            return d.cityName+d.areaName;
                        }
                    },
                    {
                        field: 'address',
                        title: '详细地址',
                        align: 'center'
                    },
                    {
                        field: 'hostType',
                        title: '房屋类型',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictDataurl, 'host_host_type', d.hostType);
                        }
                    },
                    {
                        field: 'shareType',
                        title: '分销状态',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'host_share_type', d.shareType);
                        }
                    },
                    {
                        field: 'hotSaleState',
                        title: '热卖新房',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'host_share_type', d.hotSaleState);
                        }
                    },
                    {
                        field: 'sort',
                        title: '序号',
                        align: 'center'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: '操作',
                        width: 150,
                        templet: '#entityBar',
                        align: "center",
                        fixed: 'right'
                    }];
                tableIns = pageUtil.initDate(cols, url, true);
            });
            });
        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/hostItem/getEntity?id=" + data.id);
                } else if (layEvent === 'showPicture') {
                    fileUtil.imageSingleShow(data.coverImage);
                }  else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/hostItem/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                }
            });
    })</script>
</body>

</html>